﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace muiscsys.李桥峰
{
    public partial class Denglu : Form
    {
        public Denglu()
        {
            InitializeComponent();
        }

        private void deng_Click(object sender, EventArgs e)
        {
            string zhanghao = this.textBox1.Text.Trim();
            string mima = this.textBox2.Text.Trim();
            bool result = CheckLogin(zhanghao, mima);
            if (result)
            {
                MessageBox.Show("登录成功！");

            }
            else
            {
                MessageBox.Show("登录失败！");
            }
        }
        public static bool CheckLogin(string zhanghID, string pwd)
        {
            SqlConnection conn = new SqlConnection("Data Source=LAPTOP-FVVSPTG4;Initial Catalog=Bofangqi;Integrated Security=True");
            conn.Open();
            string sql = string.Format(@"select count(*) from Zhu where ZhangID='{0}' and[PassWord]='{1}'", zhanghID, pwd);
            SqlCommand com = new SqlCommand(sql, conn);
            int count = Convert.ToInt32(com.ExecuteScalar());
            if (count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
